package thread;

import sun.security.krb5.internal.Ticket;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class Test extends JFrame {
    private JTextArea[] ta=new JTextArea[3];
    public Test(){
        setTitle("售票");
        setSize(1000,500);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLayout(null);
        int x=40;
        for (int i=0;i<3;i++){
            ta[i]=new JTextArea();
            JScrollPane sp=new JScrollPane(ta[i]);
            sp.setBounds(x,10,300,300);
            add(sp);
            x+=310;

        }
        JButton btn=new JButton("开始");
        btn.setBounds(400,350,200,25);
        add(btn);
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                for (int i=0;i<3;i++)
                    ta[i].setText("");
                List<Ticks> list=new ArrayList<>();
                for (int i=0;i<10;i++){
                    list.add(new Ticks(i+1));
                }
                SailTick st1=new SailTick(list,ta[0]);
                SailTick st2=new SailTick(list,ta[1]);
                SailTick st3=new SailTick(list,ta[2]);
                st1.start();st2.start();st3.start();
            }
        });

    }
    public  static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Test();
            }
        });
    }
}
